Listen to Cell Changes and Action

From Documentation


Listen to Cell Changes and Action




Stop.png This article is out of date, please refer to http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials for more up to date information.


Users can write cell change event listeners for those cases when cells' values or styles are changed.

Purpose

Implement cell change event listeners for cell contents changes.

Cell Change Event

There are one cell change event. onCellChange - This event is fired when user change the contents or styles of a selection directly or indirectly. Event listeners are provided with CellSelectionEvent in the event listener.

Registering Cell Events

Cell change event can be registered to ZK Spreadsheet either by calling AbstractComponent.addEventListener(String, EventListener) or by using ZK MVC way i.e. using naming convention of <event-name>$<component-id>. Here is an example shown using first way

...
ss.addEventListener(org.zkoss.zss.ui.event.Events.ON_CELL_CHANGE,
	new EventListener() {
		public void onEvent(Event event) throws Exception {
			doCellChangeEvent((CellSelectionEvent) event);
		}
	});
...

Note: All ZK Spreadsheet supported events have a corresponding static constants declared in org.zkoss.zss.ui.event.Events class. For example for onCellChange event there is org.zkoss.zss.ui.event.Events.ON_CELL_CHANGE.

Here is an example shown using second way

...
public void onCellChange$ss(CellSelectionEvent event) {
	doCellChangeEvent(event);
}
...

Version History

Last Update : 2013/08/22


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2013/08/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.